// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;
using System.Security.Cryptography.Asn1;

namespace System.Security.Cryptography.X509Certificates.Asn1
{
    // https://tools.ietf.org/html/rfc2986#section-4.1
    //
    // CertificationRequestInfo ::= SEQUENCE {
    //     version INTEGER { v1(0) } (v1,...),
    //     subject Name,
    //     subjectPKInfo SubjectPublicKeyInfo{ { PKInfoAlgorithms } },
    //     attributes[0] Attributes{ { CRIAttributes } }
    // }
    [StructLayout(LayoutKind.Sequential)]
    internal sealed class CertificationRequestInfoAsn
    {
        internal byte Version;

        [AnyValue]
        [ExpectedTag(TagClass.Universal, (int)UniversalTagNumber.SequenceOf)]
        internal ReadOnlyMemory<byte> Subject;

        internal SubjectPublicKeyInfoAsn SubjectPublicKeyInfo;

        [ExpectedTag(0)]
        internal X501AttributeAsn[] Attributes;
    }
}
